package src.com.foreknow.demo11;

public class AnimalTest {
    public static void main(String[] args) {
        Animal animal = new Cat("加菲猫",4);
        System.out.println(animal.getName());
        animal.shout();

        Animal animal1 = new Duck("唐老鸭",2);
        System.out.println(animal1.getName());
        animal.shout();

        Animal[] animals = new Animal[2];

        Cat cat = new Cat();
        cat.setName("加菲猫");
        cat.setLegNum(4);

        Duck duck = new Duck();
        duck.setName("唐老鸭");
        duck.setLegNum(2);

        animals[0] = cat;
        animals[1] = duck;

        for (int i = 0;i < animals.length;i++){
            Animal a = animals[i];
            System.out.println(a.getName());
            a.shout();
        }
    }
}









